package aqiang9.test;

import java.util.Arrays;

/**
 * 阿里面试题 int 数组 转 包装类数组
 * @authoer aqiang9
 * @create 2020--16
 */
public class IntToInteger {
    public static void main(String[] args) {
        toChage2();
    }

    /**
     * 方式一
     */
    public static void toChage(){
        int[] a = new int[]{1,2,3,4,5,6};
        Integer[] b = new Integer[a.length ] ;
        for (int i = 0; i < a.length; i++) {
            b[i] = a[i] ;
        }
        System.out.println(Arrays.toString(b));
    }

    /**
     * 方式二
     */
    public static void toChage2(){
        int[] a = new int[]{1,2,3,4,5,6};
        Integer[] integers = Arrays.stream(a).boxed().toArray(Integer[]::new);
        System.out.println(Arrays.toString(integers));
    }

}
